package com.wpw.dream.spider.processor;

import org.apache.log4j.Logger;

import com.wpw.dream.spider.dao.ContentDao;
import com.wpw.dream.spider.entity.Content;
import com.wpw.dream.spider.util.SpringContextUtils;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

public class ContentPipeline implements Pipeline {

	private ContentDao contentDao = SpringContextUtils.getBean("contentDao");
	
	private Logger logger = Logger.getLogger(ContentPipeline.class);
	
	@Override
	public void process(ResultItems resultItems, Task task) {
		Content content = resultItems.get("content");
		if (content != null) {
			logger.info("========================数据库中要存：" + content.getLinkUrl());
			contentDao.insert(content);
		}
	}

}
